﻿#region << 文 件 说 明 >>

/*----------------------------------------------------------------
// 文件名称：EditItem
// 创 建 人：YangCheng
// 创建时间：2022/6/30 16:34:59
// 文件版本：V1.0.0
// ===============================================================
// 功能描述：
//
//
//----------------------------------------------------------------*/

#endregion

namespace Vampirewal.Core.WPF.Theme;

/// <summary>
///
/// </summary>
public class EditItem : ListBoxItem
{
    /// <summary>
    /// 
    /// </summary>
    public string HeaderText { get; set; }

    static EditItem()
    {
        DefaultStyleKeyProperty.OverrideMetadata(typeof(EditItem), new FrameworkPropertyMetadata(typeof(EditItem)));
    }


    /// <inheritdoc/>
    public override void OnApplyTemplate()
    {
        base.OnApplyTemplate();
        if (Template.FindName("tb_Header", this) is TextBlock tb)
        {
            tb.Text = HeaderText;
        }
    }

    /// <summary>
    /// 是否允许鼠标左键按下
    /// </summary>
    public bool IsAllowOnMouseLeftButtonDown { get; set; } = false;

    /// <summary>
    /// 屏蔽选中跳转效果
    /// </summary>
    /// <param name="e"></param>
    protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
    {
        if(!IsAllowOnMouseLeftButtonDown) 
            e.Handled = true;
    }

    #region 依赖属性

    /// <summary>
    /// 
    /// </summary>
    public Brush IconColor
    {
        get { return (Brush)GetValue(IconColorProperty); }
        set { SetValue(IconColorProperty, value); }
    }

    /// <summary>
    /// 
    /// </summary>
    public static readonly DependencyProperty IconColorProperty =
        DependencyProperty.Register("IconColor", typeof(Brush), typeof(EditItem), new PropertyMetadata(Brushes.CadetBlue));

    /// <summary>
    /// 
    /// </summary>
    public Brush TitleColor
    {
        get { return (Brush)GetValue(TitleColorProperty); }
        set { SetValue(TitleColorProperty, value); }
    }

    /// <summary>
    /// 
    /// </summary>
    public static readonly DependencyProperty TitleColorProperty =
        DependencyProperty.Register("TitleColor", typeof(Brush), typeof(EditItem), new PropertyMetadata(Brushes.DarkBlue));




    #endregion
}